jQuery(document).ready(function($) {
  if(!(window.XMLHttpRequestUpload && window.FileReader)) {
    $('#uploadlicenseform .btn-upload').html($('#uploadlicenseform .btn-upload').data('nodragtext'));
  }
 
  jQuery('#uploadlicenseform').fileUploadUIX({
      allowDocImageType: true,
       
      maxFileSize: 4*1024*1024,
      keepList: false,
      autoUpload: true, 
      onCompleteAll: function(list) {
         var errors = []; 
         var success = []; 
         jQuery.each(list, function(i, o) {
            var handler = o.slice(-1)[0]; 
            if(handler.response.error && handler.response.error.length > 0) {
               errors[errors.length] = handler.response.name; 
            }
            else
               success[success.length] = handler.response.name;
         });

         if(errors.length > 0 || success.length <= 0)
            return; 

         var p = jQuery("#uploadlicenseform");
         p.parent().hide();
         p.parent().next().fadeIn();
         p.parent().prev().hide();
         p.parent().prev().prev().hide();
         p.jobUtil("timerDown", function() {
            window.location.reload(true);
         }, 3);
      }
  }); 

});

